/**
 * Created by huachuan on 2016/1/6.
 */
//获取本周的时间所有时间
function getWeekDay(nowDate) {
  var now = nowDate;
  var nowDayOfWeek = now.getDay();         //今天本周的第几天
  var nowDay = now.getDate();              //当前日
  var nowMonth = now.getMonth();           //当前月
  var nowYear = now.getYear();
  var weekDay = [];
  nowYear += (nowYear < 2000) ? 1900 : 0;//当前年
  for (var i = nowDay - nowDayOfWeek; i <= nowDay + (6 - nowDayOfWeek); i++) {
    var dayShow = {
      time: '',
      timeformat: '',
      selected: false
    };
    dayShow.time = new Date(nowYear, nowMonth, i);
    dayShow.timeformat = formatDate(new Date(nowYear, nowMonth, i));
    if (formatDate(new Date(nowYear, nowMonth, i)) == formatDate(now)) {//如果是当天的日期
      dayShow.selected = true;
    }
    weekDay.push(dayShow);
  }
  return weekDay;
}

//格式化时间
function formatDate(date) {
  var nowYear = date.getYear();
  nowYear += (nowYear < 2000) ? 1900 : 0;//当前年
  var mymonth = date.getMonth() + 1;
  var myweekday = date.getDate();
  if (mymonth < 10) {
    mymonth = "0" + mymonth;
  }
  if (myweekday < 10) {
    myweekday = "0" + myweekday;
  }
  return (nowYear + "-" + mymonth + "-" + myweekday);
}
function formatDateDetail(now) {
  var nowYear = now.getYear();
  nowYear += (nowYear < 2000) ? 1900 : 0;//当前年
  var mymonth = now.getMonth() + 1;
  var myweekday = now.getDate();
  if (mymonth < 10) {
    mymonth = "0" + mymonth;
  }
  if (myweekday < 10) {
    myweekday = "0" + myweekday;
  }
  var hour=now.getHours();
  var minute=now.getMinutes();
  var second=now.getSeconds();
  return nowYear+"-"+mymonth+"-"+myweekday+" "+hour+":"+minute+":"+second;
}
//去除数组的重复项
function unique(arr) {
  var result = [], isRepeated;
  for (var i = 0, len1 = arr.length; i < len1; i++) {
    isRepeated = false;
    for (var j = 0, len2 = result.length; j < len2; j++) {
      if (arr[i].member_id == result[j].member_id) {
        isRepeated = true;
        break;
      }
    }
    if (!isRepeated) {
      result.push(arr[i]);
    }
  }
  return result;
}
